<%--
   Copyright 2010-2013 Bornil Photography

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page session="false"%>
<%@ include file="/WEB-INF/views/includes.jsp" %>
<!DOCTYPE HTML>
<html>
    <head>
        <title><spring:message code="menu.event.mgmt"/></title>
        <link rel="stylesheet" href="${pageContext.request.contextPath}/<spring:theme code="styleSheet"/>" type="text/css"/>
    </head>
    <body>
    
        <spring:hasBindErrors name="event">
            <c:forEach items="${errors.globalErrors}" var="error">
            <ul class="errors">
                <li><spring:message code="${error.code}" arguments="${error.arguments}"/></li>
            </ul>
            </c:forEach>
        </spring:hasBindErrors>
   
        <c:if test="${! empty eventList}"> 
        <table>
            <thead>
                <th><spring:message code="lbl.event.classification"/></th>
                <th><spring:message code="lbl.created.by"/></th>
                <th></th>
            </thead>
		    <c:forEach var="event" items="${eventList}">
		       <tr>
	               <td>${event.evtClass}</td>
	               <td>${event.createdBy}</td>
	               <td>
	                   <spring:url value="/event/editEvent/{evtId}" var="eventEditUrl"><spring:param name="evtId" value="${event.evtId}"/></spring:url>
	                   <a href="${fn:escapeXml(eventEditUrl)}"><spring:message code="lbl.edit"/></a>
	               </td>
	           </tr>
	        </c:forEach>
        </table>
        </c:if>
        
        <%-- Ques: what is the clean way to handle action tag context specific URL? --%>
        <spring:url value="/event/eventSearch" var="postUrl"/>
        <form:form modelAttribute="event" method="post" action="${ postUrl }">
            <spring:message code="lbl.event.id"/>:
            <form:input path="evtId"/><form:errors path="evtId" cssClass="errors"/><br/><input type="submit" value="Search"/><a href="<spring:url value='/event/newEvent' />"><spring:message code="lbl.new"/></a>
        </form:form>  
        
        <ul>
	        <li><a href="<spring:url value='/' />"><spring:message code="menu.home"/></a></li>
        </ul>
    </body>
</html>